package net.koodar.forge.mybatis.doman;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.time.LocalDateTime;

/**
 * Base entity.
 *
 * @author liyc
 */
@Data
@ToString
@EqualsAndHashCode(callSuper = true)
public class BaseEntity<T extends Model<?>>  extends Model<T> {

	@Schema(description = "创建者ID")
	@TableField(value = "creator_id", fill = FieldFill.INSERT)
	private Long creatorId;

	@Schema(description = "创建时间")
	@TableField(value = "create_time", fill = FieldFill.INSERT)
	private LocalDateTime createTime;

	@Schema(description = "更新者ID")
	@TableField(value = "updater_id", fill = FieldFill.UPDATE, updateStrategy = FieldStrategy.NOT_NULL)
	private Long updaterId;

	@Schema(description = "创建时间")
	@TableField(value = "create_time", fill = FieldFill.UPDATE)
	private LocalDateTime updateTime;
}
